import gameConfig from '../../engines/configs/gameConfig';
import { GAME_MODE } from '../../engines/managers/gameContent/gameMode_json';
import PageBase from '../Base/PageBase';
import { IPagePramsBase } from '../Interface';
import ModeBtn from '../Obj/ModeBtn';

const { ccclass, property, menu, disallowMultiple } = cc._decorator;

@ccclass
@disallowMultiple
@menu('游戏页面/模式选择页')
export default class ModeMenu extends PageBase {
    @property({ type: cc.ScrollView, displayName: "按钮卷动页" })
    private m_mainView: cc.ScrollView = null;
    @property({ type: cc.Prefab, displayName: "模式选择按钮的预制体" })
    private m_modeBtnPrfab: cc.Prefab = null;

    async OnPageOpen(prams: IPagePramsBase) {
        super.OnPageOpen(prams);
        let array = gameConfig.MENU_SHOW_MODE;//暂时关掉配置
        // let array =[17,14,8,7,1,2,3,11,20]
        for (let index = 0; index < array.length; index++) {
            const element = array[index];
            if (Object.values(GAME_MODE).includes(element)) {
                console.debug('more mode', element);
                let node = cc.instantiate(this.m_modeBtnPrfab);
                let com = node.getComponent(ModeBtn);
                com.BtnInit(element);
                this.m_mainView.content.addChild(node);
            }
        }
    }
}